import {LikeStaffName} from "../api/index";

export const mixin = {
  methods : {
    //提示信息
    notify(title,type){
      this.$notify({
        title:title,
        type:type
      })
    },
    //获取图片地址
    attachImageUrl(srcUrl) {
      return srcUrl ? srcUrl : 'http://localhost:8888/69d4558ebfe5440190e65f92351c47e9.jpg';
    },
    //获取生日
    attachBirth(val) {
      return val.substr(0, 10);
    },
    //模糊查询乐谱名
    getStaff(){
      if (!this.$route.query.keywords){
            this.$store.commit('setListOfStaffs',[])
            this.notify('您输入的内容为空','warning')
      }else {
          LikeStaffName(this.$route.query.keywords).then(res =>{
            const data = res.data;
          if (!data.length){
            this.$store.commit('setListOfStaffs',[])
            this.notify('系统暂无符合条件的乐谱','warning');
          }else {
            this.$store.commit('setListOfStaffs',data)
          }
        }).catch(err =>{
          console.log(err)
        })
      }

    }
  }
}
